#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include<QPoint>
#include<QProgressBar>
#include<QPushButton>
#include<QListWidget>
#include<QListWidgetItem>
#include<QScrollArea>
#include<QStackedWidget>
#include<QNetworkAccessManager>
#include<QNetworkReply>
#include<QNetworkRequest>
#include<QThread>
#include<QList>
#include<QMouseEvent>
#include<QPoint>
#include<QRandomGenerator>
#include<QMediaPlayer>
#include<QAudioOutput>
#include"browse_.h"
#include"community_.h"
#include"downloadmgr.h"
#include"lastmusic.h"
#include"localmusic.h"
#include"mycollection.h"
#include"mypodcast.h"
#include"mylove.h"
#include"mymusicyun.h"
#include"podcast.h"
#include"recommend.h"
#include"searchwidget.h"
#include"yunselected.h"
#include"soundwidget.h"
#include"httpgetthread.h"
QT_BEGIN_NAMESPACE

class MediaPlay;
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private:
    void initWid();       //初始化上方widget
    void initList();     //初始化左侧导航栏
    void initStack();    //初始化主体窗口
    void initBottom();   //初始化下方widget
    void initConnect();  //信号与槽连接
    void nextSong();    //下一首歌
    void playSong(int index);   //播放歌曲
    void soundChange(int t);    //调整音量
protected:
    void mouseMoveEvent(QMouseEvent *event);
    void mousePressEvent(QMouseEvent *event);
    void mouseReleaseEvent(QMouseEvent *event);

private slots:
    void slot_close();
    void slot_big();
    void slot_small();
    void slot_normal();
    void slot_curchange(int t);
    void slot_curchange_2(int t);
    void on_search_edit_returnPressed();
    void timeChange(int t);
    void slot_search_doublePress(int index);

    void on_sound_btn_clicked();

    void on_pushButton_10_clicked();

    void on_mode_btn_clicked();

    void slot_nextSong();

    void slot_upSong();
private:
    Ui::MainWindow *ui;

    QScrollArea* scro;
    QListWidget* list1;
    QListWidget* list2;
    QStackedWidget* stack;
    browse_* _browse;
    community_* _community;
    DownloadMgr* _downLoadMgr;
    LastMusic* _lastMusic;
    LocalMusic* _localMusic;
    MyCollection* _myCollection;
    MyLove* _myLove;
    MyMusicYun* _myMusicYun;
    MyPodcast* _myPodcast;
    Podcast* _podcast;
    recommend* _recommend;
    SearchWidget* _searchWid;
    YunSelected* _yunSelect;
    SoundWidget* soundWid;
    HttpGetThread* http_get_thread;
    QMediaPlayer* _MediaPlayer;
    playType _playType;
    int nowIndex;
    bool is_online_play;
    bool is_start;
    QThread* playSongThread;
    MediaPlay* _mediaPlay_obj;
    QPoint last={0,0};
    bool is_press_move=false;

signals:
    void sig_playSong(QMediaPlayer *MediaPlayer, int index, QList<songInfo> songList,
                      bool* is_online_play,bool* is_start,QPushButton*button,QProgressBar* progressbar);
};

class MediaPlay:public QObject{
    Q_OBJECT
private:

public:
    explicit MediaPlay(QObject*parent=nullptr);
    void playSong(QMediaPlayer *MediaPlayer, int index, QList<songInfo> songList,
                  bool* is_online_play,bool* is_start,QPushButton*button,QProgressBar* progressbar);
};

#endif // MAINWINDOW_H
